package com.etop.jansing.entities;

import org.hibernate.annotations.Fetch;
import org.hibernate.annotations.FetchMode;

import javax.persistence.*;
import java.util.ArrayList;
import java.util.List;

/**
 * Created by jansing on 2015/10/25.
 */
@Entity
@Table(name="role")
public class Role extends BaseEntity{
    @Column(name="name")
    private String name;

    @OneToMany(targetEntity = ResourcePermission.class, fetch = FetchType.LAZY)
    @Fetch(FetchMode.SUBSELECT)
    @JoinTable(name="roleresourcepermission", joinColumns = {@JoinColumn(name="rid")}
            , inverseJoinColumns = {@JoinColumn(name="rpid")})
    private List<ResourcePermission> resourcePermissionList = new ArrayList<>();

    public Role() {
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public List<ResourcePermission> getResourcePermissionList() {
        return resourcePermissionList;
    }

    public void setResourcePermissionList(List<ResourcePermission> resourcePermissionList) {
        this.resourcePermissionList = resourcePermissionList;
    }
}
